applying reimann sum for the midpoint rule